float theta;	//increment by pi/16 from 0 to pi/2, 9 total values
float epsilon;	//increment by 0.1 from 0 to 1.0, 11 total values
int x;			//x position of ball
int y;			//y position of ball
int velocityx;
int velocityy;
int	gravity;
	
main() {
	init();
	while 1 {
		buttonPresses = RisingEdgesOfInport0();
		if (buttonPresses & 0x01) {
			IncreaseTheta();

		}
		else if (buttonPresses & 0x02) {
			DecreaseTheta();
		}
		else if (buttonPresses & 0x04) {
			IncreaseEpsilon();
		}
		else if (buttonPresses & 0x08) {
			DecreaseEpsilon();
		}
		else if (buttonPresses & 0x10) {
			Fire();
		}
		else if (timerinterrput) {
			calculateNewPosition();
		}
		
		if (x > maxX)	//ball is past the screen, refire it
			Fire();
			
		outport0 = x;
		outport1 = y;
	}
}

init() {
	theta = pi/4;
	epsilon = 0.5;
}

//fires new ball with current theta and epsilon
Fire() {
	x = 0;
	y = 0;
	velocityx = ;	//TODO set this somehow
	velocityy = ;	//TODO set vertical V0
}

IncreaseTheta() {
	if (theta >= pi/2) {
		return;
	}
	theta += pi/16
}

DecreaseTheta() {
	if (theta <= 0) {
		return;
	}
	theta += pi/16
}

IncreaseEpsilon() {
	if (epsilon >= 1) {
		return;
	}
	epsilon += 0.1
}

DecreaseEpsilon() {
	if (epsilon <= 0) {
		return;
	}
	epsilon += 0.1
}

calculateNewPosition() {
	x += velocityx;
	velocityy += gravity;
	y += velocityy;
	
	if (y <= 0) {
		y = 0;
		velocityy *= -1*epsilon;
	}
}